package qqmeeting

import (
	"errors"
	"fmt"
	"net/http"
)

type CancelMeetingBody struct {
	Userid       string `json:"userid"`
	Instanceid   int    `json:"instanceid"`
	ReasonCode   int    `json:"reason_code"`
	ReasonDetail string `json:"reason_detail"`
}

//CancelMeeting 取消会议
func (c *Client) CancelMeeting(meetingID string, body CancelMeetingBody) (err error) {
	uri := fmt.Sprintf("/v1/meetings/%s/cancel", meetingID)
	var statusCode int
	var content []byte
	if statusCode, content, err = c.POST(uri, body); err != nil {
		return
	}
	if statusCode != http.StatusOK {
		if content != nil {
			err = errors.New(string(content))
		} else {
			err = fmt.Errorf("[%d] Bad request", statusCode)
		}
	}
	return
}
